package com.crm.service.impl.taskManager;

import com.crm.dao.mapper.customMapper.taskCustomManager.TaskInfoCustomMapper;
import com.crm.dao.mapper.taskManager.TaskInfoMapper;
import com.crm.model.entity.taskManager.TaskInfo;
import com.crm.model.qo.taskManager.TaskInfoQO;
import com.crm.model.vo.taskManager.TaskInfoVO;
import com.crm.model.vo.taskManager.TodayTaskVO;
import com.crm.service.taskManager.TaskInfoDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Author renshaorong
 * @Date 2021/04/25 4:40 下午
 */
@Service
public class TaskInfoDbServiceImpl implements TaskInfoDbService {

    @Autowired
    private TaskInfoCustomMapper taskInfoCustomMapper;

    @Autowired
    private TaskInfoMapper taskInfoMapper;

    /**
     * 获取所有任务列表
     * @param taskInfoQO
     * @param toString
     * @return
     */
    @Override
    public List<TaskInfoVO> getAllTaskInfoByAccountId(TaskInfoQO taskInfoQO, String toString) {
        return taskInfoCustomMapper.getAllTaskInfoByAccountId(taskInfoQO,toString);
    }

    /**
     * 保存任务
     * @param taskInfo
     * @return
     */
    @Override
    public boolean saveTaskInfo(TaskInfo taskInfo) {
        return taskInfoMapper.insertSelective(taskInfo) > 0;
    }

    /**
     * 根据主键查询任务信息
     * @param taskId
     * @return
     */
    @Override
    public TaskInfo getTaskInfoByTaskId(String taskId) {
        return taskInfoMapper.selectByPrimaryKey(taskId);
    }

    /***
     * @Description:用户端-任务列表—本日任务
     * @Param:accountId 账号id
     * @Param:date 查询日期
     * @Author: luojie
     * @Date: 2021/4/26 18:08
     */
    @Override
    public List<TodayTaskVO> getTodayTask(String accountId, Date selectDate) {
        List<TodayTaskVO> todayTask = taskInfoCustomMapper.getTodayTask(accountId,selectDate);
        return todayTask;
    }

    @Override
    public boolean updateTaskInfo(TaskInfo taskInfo) {
        return taskInfoMapper.updateByPrimaryKeySelective(taskInfo) > 0;
    }
}
